import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class TaskService {
    constructor(private requestclass: RequestClass) {}
    fetchTaskByNone = async () => {
        return await this.requestclass.request.Pget('/job/getalljobtasks');
    };

    addTaskByConfig = async ({
        beanClass,
        createTime,
        createUser,
        cronExpression,
        jobDescription,
        jobGroup,
        jobName,
        jobStatus,
        updateTime,
        updateUser,
    }) => {
        return await this.requestclass.request.post('/job/insertjobtask', {
            data: {
                beanClass,
                createTime,
                createUser,
                cronExpression,
                jobDescription,
                jobGroup,
                jobName,
                jobStatus,
                updateTime,
                updateUser,
            },
        });
    };

    editTaskByConfig = async ({
        id,
        beanClass,
        createTime,
        createUser,
        cronExpression,
        jobDescription,
        jobGroup,
        jobName,
        jobStatus,
        updateTime,
        updateUser,
    }) => {
        return await this.requestclass.request.put('/job/updatejobtask', {
            data: {
                id,
                beanClass,
                createTime,
                createUser,
                cronExpression,
                jobDescription,
                jobGroup,
                jobName,
                jobStatus,
                updateTime,
                updateUser,
            },
        });
    };

    editTaskCronById = async ({ jobId, cronExpression }) => {
        return await this.requestclass.request.put('/job/updatecron', {
            params: {
                jobId,
                cronExpression,
            },
        });
    };

    editTaskStatusById = async ({ id, jobStatus }) => {
        return await this.requestclass.request.put('/job/changejobstatus', {
            params: {
                id,
                jobStatus,
            },
        });
    };

    deleteTaskById = async ({ id }) => {
        return await this.requestclass.request.delete('/job/deletejobtask', {
            params: {
                id,
            },
        });
    };
}
